package com.calligraphy.user.converter;

import com.calligraphy.bases.utils.HashUtil;
import com.calligraphy.bases.utils.KeyUtil;
import com.calligraphy.user.from.UserFrom;
import com.calligraphy.user.model.User;
import lombok.extern.slf4j.Slf4j;

/**
 * @Author hy
 * @Date 2018/12/13 20:21
 **/
@Slf4j
public class UserFrom2UserConverter {

    public static User convert(UserFrom userFrom) {
        User user = new User();
        user.setUserId(KeyUtil.genUniqueKey());
        user.setUserName(userFrom.getUserName());
        user.setPassWord(HashUtil.encryPassword(userFrom.getPassWord()));
        user.setUserIcon(userFrom.getUserIcon());
        user.setEmail(userFrom.getEmail());
        user.setPhone(userFrom.getPhone());
        user.setAddress(userFrom.getAddress());
        return user;

    }
}
